import React, { PureComponent, memo, createRef, forwardRef } from "react"
import ReactDOM from "react-dom"

const Child = memo(forwardRef(function Child(props, ref) {
    return (
        <div className="child" ref={ref}>
            {props.age}
        </div>
    )
}))
class App extends PureComponent {
    constructor(props) {
        super(props)
        this.state = {
            messgae: "你好啊 webpack 打包的 react",
            age: 19
        }
        this.childRef = createRef()
    }
    render() {
        return (
            <>
                <div>{this.state.messgae}</div>
                <Child ref={this.childRef} {...this.state} />
            </>
        )
    }
    componentDidMount() {
        setTimeout(() => {
            console.log(this);
            console.log(this.childRef.current);
            this.childRef.current.innerHTML = "12312312"
        }, 3000);
    }
}
ReactDOM.render(<App />, document.getElementById("app"))